import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<Object> products = new ArrayList<Object>();
        products.add("离");
        products.add("离");
        products.add("原");
        products.add("上");
        products.add("草");

        AbstractObjectList list;
        IIterator iterator;

        list = new ProductList(products);
        iterator = list.createIterator();

        System.out.println("正着背：");
        while(!iterator.isLast()) {
            System.out.print(iterator.getNextItem());
            iterator.next();
        }
        System.out.println();
        System.out.println("-----------------------------");
        System.out.println("倒着背：");
        while(!iterator.isFirst()) {
            System.out.print(iterator.getPreviousItem());
            iterator.previous();
        }
    }

}
